package com.ruibei.ui.fragment;

import butterknife.ButterKnife;
import butterknife.InjectView;

import com.ruibei.R;
import com.ruibei.ui.CalculatorActivity;
import com.ruibei.ui.NewProductApprovActivity;
import com.ruibei.view.TitleBarView;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;

/**
 * 操作页面
 *
 * @author limingyan
 *
 */
public class OperationFragment extends BaseFragment implements OnClickListener{
	private static final String TAG = "OperationFragment";
	private Context mContext;
	@InjectView(R.id.btn_computer)
	Button computerBtn;
	
	@InjectView(R.id.btn_new_product)
	Button newProductBtn;
	//标题栏
	private TitleBarView mTitleBarView;
	private View mBaseView;
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		mContext = getActivity();
		mBaseView= inflater.inflate(R.layout.fragment_operation, container,
				false);
		ButterKnife.inject(this, mBaseView);
		
		initTitleView();
		initListener();
		
		return mBaseView;
	}
	
	private void initTitleView(){
		mTitleBarView = (TitleBarView) mBaseView.findViewById(R.id.operation_title_bar);
		mTitleBarView.setCommonTitle(View.GONE, View.VISIBLE, View.GONE);
		mTitleBarView.setTitleText(R.string.operation_title);
	}
	
	private void initListener(){
		computerBtn.setOnClickListener(this);
		newProductBtn.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch(v.getId()){
			case R.id.btn_computer:
				startActivity(new Intent(OperationFragment.this.getActivity(), CalculatorActivity.class));
				break;
			case R.id.btn_new_product:
				startActivity(new Intent(OperationFragment.this.getActivity(), NewProductApprovActivity.class));
				break;
		}
	}
}
